package com.swh.controller.Institutional;

import com.github.pagehelper.PageInfo;
import com.swh.entity.QualificationCondition;
import com.swh.entity.SysOffice;
import com.swh.service.SysOfficeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/14 14:41
 * @Version: 1.0
 */
@Controller
@RequestMapping("/guguanjia/office")
public class SysOfficeController {

    @Autowired
    private SysOfficeService sysOfficeService;

    @RequestMapping("/index")
    public String login() {
        return "office/office";
    }
//
//
    @ResponseBody
    @RequestMapping("/findAll")
    public List<SysOffice> findAll() {
        SysOffice sysOffice = new SysOffice();
        sysOffice.setDelFlag("0");
        return sysOfficeService.findAll(sysOffice);
    }
//
    @ResponseBody
    @RequestMapping("/selectPage/{pageNum}/{pageSize}")
    public PageInfo<HashMap> selectPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize,
                                        QualificationCondition condition) {
        return sysOfficeService.selectPage(pageNum, pageSize, condition);
    }
//
    @RequestMapping("/toUpdate")
    public String toUpdate() {
        return "/office/update";
    }
//
    @ResponseBody
    @RequestMapping("/get")
    public Object get(Integer id) {
        return sysOfficeService.findById(id);
    }
//
    //删除//修改
    @ResponseBody
//    @CacheEvict(cacheNames = Office.SYS_OFFICE_KEY,allEntries = true)
    @RequestMapping(value = "/updateById", method = RequestMethod.POST)
    public void updateById(@RequestBody SysOffice sysOffice) {
        sysOfficeService.update(sysOffice);
    }
//
    //删除//修改
    @ResponseBody
//    @CacheEvict(cacheNames = Office.SYS_OFFICE_KEY,allEntries = true)
    @RequestMapping(value = "/updateById2", method = RequestMethod.POST)
    public void updateById2(@RequestBody SysOffice sysOffice) {
        sysOfficeService.update2(sysOffice);
    }

}
